from django.db import models

# Create your models here.

# 图书类
class BookInfo(models.Model):
    '''图书模型类'''
    btitle = models.CharField(max_length=20)
    bpub_date = models.DateField()

    def __str__(self):
        # 返回书名
        return self.btitle


class HeroInfo(models.Model):
    hname = models.CharField(max_length=20) # 名称
    hgender = models.BooleanField(default=False) #性别 False 男
    hcomment = models.CharField(max_length=128) #备注
    hbook = models.ForeignKey('BookInfo', on_delete=models.CASCADE)

    def __str__(self):
        # 返回书名
        return self.hname